<template>
  <div class="upload-container">
    <el-upload
      class="upload-demo"
      :action="uploadurl"
      :headers="uploadheaders"
      :data="uploaddata"
      :multiple="false"
      list-type="picture"
      :show-file-list="false"
      :on-success="uploadSuccess"
    >
      <el-button size="small" type="primary" icon="el-icon-upload">上传图片</el-button>
    </el-upload>
  </div>
</template>

<script>
import { config } from '@/utils/requestconfig'
import { getToken } from '@/utils/auth'
export default {
  data() {
    return {
      uploadurl: config.webapi + 'Upload/UploadFiles',
      uploadheaders: { Authorization: getToken() },
      uploaddata: { dir: 'activity' }
    }
  },
  methods: {
    uploadSuccess(res, file) {
      if (res.IsSuccess && res.Data.length > 0) {
        // this.temp.FormatLogoUrl = res.Data.Src;
        // this.temp.LogoUrl = res.Data.Path;
        this.$emit('successCBK', res.Data[0].previewPath)
      }
    }
  }

}
</script>
